package com.dcw.lixb.designmode.filter;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author lixiaobin
 * @date 2020-07-21 15:24:55
 * @desc 描述信息
 */
public class OrCriteria implements Criteria {

    private final Criteria[] mCriterias;

    public OrCriteria(Criteria ... criterias){
        mCriterias = criterias;
    }

    @Override
    public List<Person> meetCriteria(List<Person> persons) {
        Set<Person> personSet = new HashSet<>();
        if (null != mCriterias) {
            for (Criteria ct : mCriterias) {
                personSet.addAll(ct.meetCriteria(persons));
            }
        }
        return new ArrayList<>(personSet);
    }
}
